import request from '@/utils/request'

export function getDocumentUsableList(query) {
  let baseUrl = "/marketing/document"
  if(query != undefined){
    if(typeof query == "object"){
      console.log(query)
      if(query.hasOwnProperty('documentID')){
        query['documentID'] = parseInt(query['documentID'])
        if(isNaN(query['documentID']) == false){
          baseUrl = baseUrl+"-"+query['documentID']
        }
      }
    }
  }
  return request({
    url: baseUrl,
    method: 'get'
  })
}

export function getDocumentList(query) {
  return request({
    url: '/marketing/admin/document/getList',
    method: 'post',
    data: query
  })
}
export function saveDocument(query) {
  return request({
    url: '/marketing/admin/document/save',
    method: 'post',
    data: query
  })
}

export function removeDocument(query) {
  return request({
    url: '/marketing/admin/document/remove',
    method: 'post',
    data: query
  })
}
export function getDocumentDetail(query) {
  if(query != undefined){
    query = JSON.parse(JSON.stringify(query))
  }
  return request({
    url: '/marketing/admin/document/info/0',
    method: 'get',
    data: query
  })
}